from Tkinter import *

class MainFrame:
	
	def __init__(self, controller):
		
		self.master = Tk()
		self.master.title("Anonymouth: Anti-Stylometry")
		
		frame = Frame(self.master)
		frame.pack()
		
		menubar = Menu(self.master)

		filemenu = Menu(menubar, tearoff=0)
		filemenu.add_command(label="New Project", command=func2)
		filemenu.add_command(label="Open", command=func2)
		filemenu.add_command(label="Save", command=func2)
		filemenu.add_command(label="Save As...", command=func2)
		recentmenu = Menu(filemenu, tearoff=0)
		recentmenu.add_command(label="etc", command=func2)
		filemenu.add_cascade(label="Recent Projects", menu=recentmenu)
		filemenu.add_command(label="Close Project", command=func2)
		filemenu.add_separator()
		filemenu.add_command(label="Export Project", command=func2)
		filemenu.add_separator()
		filemenu.add_command(label="Print...", command=func2)
		filemenu.add_separator()
		filemenu.add_command(label="Quit", command=self.master.quit)
		menubar.add_cascade(label="File", menu=filemenu)
		
		editmenu = Menu(menubar, tearoff=0)
		editmenu.add_command(label="Undo", command=func2)
		editmenu.add_command(label="Redo", command=func2)
		editmenu.add_command(label="Cut", command=func2)
		editmenu.add_command(label="Copy", command=func2)
		editmenu.add_command(label="Paste", command=func2)
		editmenu.add_separator()
		editmenu.add_command(label="Find", command=func2)
		editmenu.add_command(label="Find/Replace", command=func2)
		menubar.add_cascade(label="Edit", menu=editmenu)
		
		toolsmenu = Menu(menubar, tearoff=0)
		toolsmenu.add_command(label="Manage Corpus", command=func2)
		presetmenu = Menu(toolsmenu, tearoff=0)
		presetmenu.add_command(label="etc", command=func2)
		toolsmenu.add_cascade(label="Preset Corpus", menu=presetmenu)
		menubar.add_cascade(label="Tools", menu=toolsmenu)
		
		windowmenu = Menu(menubar, tearoff=0)
		#Stuff
		menubar.add_cascade(label="Window", menu=windowmenu)
		
		helpmenu = Menu(menubar, tearoff=0)
		helpmenu.add_command(label="Tutorial", command=func2)
		helpmenu.add_command(label="Conents", command=func2)
		helpmenu.add_separator()
		helpmenu.add_command(label="About", command=func2)
		menubar.add_cascade(label="Help", menu=helpmenu)
		
		
		self.master.config(menu=menubar)
		
		self.text_area = Text(frame, background='white')
		#self.text_area.pack(side=TOP)
		self.text_area.grid(row=0, column=0, rowspan=6, sticky=E+W+S+N)
		
		self.submitButton = Button(frame, text="SUBMIT", fg="red", command=func1)
		#self.button.pack(side=RIGHT)
		self.submitButton.grid(row=4, column=1)
		
		self.suggestionArea=Listbox(frame, font=("size=16,underline=0"),bg="#d4d0c8",selectbackground="#777777",activestyle="dotbox",width=25)
		self.suggestionArea.insert(END,"Awesomeness")
		self.suggestionArea.insert(END,"Coolness")
		showFeatureOptions(self.suggestionArea)
		self.suggestionArea.grid(row=0, column=1, sticky=N)
		self.suggestionArea=Listbox(frame, font=("size=16,underline=0"),bg="#d4d0c8",selectbackground="#777777",activestyle="dotbox",width=25)
		self.suggestionArea.insert(END,"1/11/11 11:00 PM")
		self.suggestionArea.insert(END,"1/12/11 12:00 AM")
		self.suggestionArea.grid(row=0, column=2, sticky=N)

	
	def start(self):
		self.master.mainloop()

	
def showFeatureOptions(suggestionArea):
	
   	if (suggestionArea.tk.call('tk', 'windowingsystem')=='aqua'):
   			suggestionArea.bind('<2>', lambda e: suggestionAreaCallback(suggestionArea,e))
   			suggestionArea.bind('<Control-1>', lambda e: suggestionAreaCallback(suggestionArea,e))
    	
	else:
			suggestionArea.bind('<3>', lambda e: suggestionAreaCallback(suggestionArea,e))
				
def suggestionAreaCallback(suggestionArea, e):
	
	if len(suggestionArea.curselection()) == 1:
		suggestionMenu = Menu(suggestionArea)
   		suggestionMenu.add_command(label="Replace")
   	 	suggestionMenu.add_command(label="Compare")
   	  	suggestionMenu.add_command(label="Ignore")
		suggestionMenu.post(e.x_root, e.y_root)
	'''	
	def undoText(self):
	
	def redoText(self):
	
	def toggleFeatureDropdown(self, action, suggestionArea):
	
	def activateProjectWizard(self):
	
	def newProject(self):
	
	def close(self):
	
	def cut(self):
	
	def copy(self):
	
	def paste(self):
	
	def find(self, text):
	
	def toggleFeatureArea(self):
	
	def toggleRevisionArea(self):
'''
		
		
def func1():
	print "hi there, everyone!"
	
def func2():
	print "hi there, everyone!"
	

if __name__ == '__main__': 
	#this runs when you run this file as the main
	app = MainFrame(None)
	app.start()

